import Vue from 'vue';
//配置路由
import VueRouter from 'vue-router'
import baseConfig from '@/config/config'  // 改名为baseConfig
Vue.use(VueRouter);
//1.创建组件
import Index from '@/views/index'
import Home from '@/views/home'
import Board from '@/views/board'
import Login from '@/views/login'
import NotFound from '@/views/404'
import UpdatePassword from '@/views/update-password'
import pay from '@/views/pay'
import register from '@/views/register'
import center from '@/views/center'
    import news from '@/views/modules/news/list'
    import discussdiannaozhuji from '@/views/modules/discussdiannaozhuji/list'
    import diannaozhuji from '@/views/modules/diannaozhuji/list'
    import aboutus from '@/views/modules/aboutus/list'
    import discussdiannaowaishe from '@/views/modules/discussdiannaowaishe/list'
    import diannaoxinxi from '@/views/modules/diannaoxinxi/list'
    import discussyingjianzuzhuang from '@/views/modules/discussyingjianzuzhuang/list'
    import discussbijiben from '@/views/modules/discussbijiben/list'
    import yingjianzuzhuang from '@/views/modules/yingjianzuzhuang/list'
    import bijiben from '@/views/modules/bijiben/list'
    import diannaowaishe from '@/views/modules/diannaowaishe/list'
    import jiagequjian from '@/views/modules/jiagequjian/list'
    import systemintro from '@/views/modules/systemintro/list'
    import yonghu from '@/views/modules/yonghu/list'
    import pinpai from '@/views/modules/pinpai/list'
    import config from '@/views/modules/config/list'
    import newstype from '@/views/modules/newstype/list'


//2.配置路由   注意：名字
export const routes = [{
    path: '/',
    name: '系统首页',
    component: Index,
    redirect: '/home',  // 添加重定向
    children: [{
      path: 'home',    // 修改路径
      name: '系统首页',
      component: Home,
      meta: {icon:'', title:'center', affix: true}
    },
     {
      path: '/updatePassword',
      name: '修改密码',
      component: UpdatePassword,
      meta: {icon:'', title:'updatePassword'}
    }, {
      path: '/pay',
      name: '支付',
      component: pay,
      meta: {icon:'', title:'pay'}
    }, {
      path: '/center',
      name: '个人信息',
      component: center,
      meta: {icon:'', title:'center'}
    }
      ,{
	path: '/news',
        name: '公告信息',
        component: news
      }
      ,{
	path: '/discussdiannaozhuji',
        name: '电脑主机评论',
        component: discussdiannaozhuji
      }
      ,{
	path: '/diannaozhuji',
        name: '电脑主机',
        component: diannaozhuji
      }   ,{
        path: '/shanjia-manage',
              name: '商户管理',
              component: () => import('@/views/shangjia/list')
            }
      ,{
	path: '/aboutus',
        name: '关于我们',
        component: aboutus
      }
      ,{
	path: '/discussdiannaowaishe',
        name: '电脑外设评论',
        component: discussdiannaowaishe
      }
      ,{
	path: '/diannaoxinxi',
        name: '电脑信息',
        component: diannaoxinxi
      }
      ,{
	path: '/discussyingjianzuzhuang',
        name: '硬件组装评论',
        component: discussyingjianzuzhuang
      }
      ,{
	path: '/discussbijiben',
        name: '笔记本评论',
        component: discussbijiben
      }
      ,{
	path: '/yingjianzuzhuang',
        name: '硬件组装',
        component: yingjianzuzhuang
      }
      ,{
	path: '/bijiben',
        name: '笔记本',
        component: bijiben
      }
      ,{
	path: '/diannaowaishe',
        name: '电脑外设',
        component: diannaowaishe
      }
      ,{
	path: '/jiagequjian',
        name: '价格区间',
        component: jiagequjian
      }
      ,{
	path: '/systemintro',
        name: '系统简介',
        component: systemintro
      }
      ,{
	path: '/yonghu',
        name: '用户',
        component: yonghu
      }
      ,{
	path: '/pinpai',
        name: '品牌',
        component: pinpai
      }
      ,{
	path: '/config',
        name: '轮播图管理',
        component: config
      }
      ,{
	path: '/newstype',
        name: '公告信息分类',
        component: newstype
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
    meta: {icon:'', title:'login'}
  },
  {
    path: '/board',
    name: 'board',
    component: Board,
    meta: {icon:'', title:'board'}
  },
  {
    path: '/register',
    name: 'register',
    component: register,
    meta: {icon:'', title:'register'}
  },
  
  // 保留这个正确的路由配置
  {
    path: '/shangjia/register',
    name: 'shangjia-register',
    component: () => import('@/views/shangjia-register.vue')  // 修改路径
  },
  {
    path: '/shangjia/login',
    name: 'shangjia-login',
    component: () => import('@/views/shangjia-login.vue')  // 修改路径
  },
  {
      path: '/shangjia',
      name: 'shangjia',
      component:() => import('@/views/shangjia/center.vue'),  // 直接使用商家中心组件，不使用默认布局
      meta: { title: '商户中心' },  // 将main改为Index
      children: [
        {
          path: 'center',
          component: () => import('@/views/shangjia/center'),
          name: '商户中心',
          meta: { title: '商户中心', icon: 'el-icon-s-shop' }
        },
          {
              path: 'center',
              name: '商户中心',
              component: () => import('@/views/shangjia/center.vue')  // 添加.vue后缀
          },
          {
              path: 'product',
              name: '商品管理',
              component: () => import('@/views/shangjia/product.vue')  // 添加.vue后缀
          },
          {
              path: 'bijiben-manage',
              name: '笔记本管理',
              component: () => import('@/views/shangjia/bijiben-manage.vue')  // 添加.vue后缀
          },
          {
              path: 'diannaozhuji-manage',
              name: '电脑住主机管理',
              component: () => import('@/views/shangjia/diannaozhuji-manage.vue')  // 添加.vue后缀
          },
          {
              path: 'yingjian-manage',
              name: '硬件组装管理',
              component: () => import('@/views/shangjia/yingjian-manage.vue')  // 添加.vue后缀
          },
          {
              path: 'waishe-manage',
              name: '外设管理',
              component: () => import('@/views/shangjia/waishe-manage.vue')  // 添加.vue后缀
          }
      ]
  },
  {
    path: '*',
    component: NotFound
  }
]
//3.实例化VueRouter  注意：名字
const router = new VueRouter({
  mode: 'hash',
  /*hash模式改为history*/
  routes // （缩写）相当于 routes: routes
})
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
export default router;
